<%--
  Created by IntelliJ IDEA.
  User: 25673
  Date: 2022/9/24
  Time: 17:24
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@page isELIgnored="false" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>新闻管理</title>
    <link rel="stylesheet" href="css/bootstrap.min.css" />
    <link rel="stylesheet" href="css/dashboard.css" />
    <script type="text/javascript" src="js/jquery1.12.4.min.js" ></script>
    <script type="text/javascript" src="js/bootstrap.min.js" ></script>
    <script type="text/javascript" src="js/countUp.js" ></script>
    <style>
        .mo{
            display: none;
            padding: 30px;
            margin-top: 100px;
            width: 400px;
            height: 500px;
            background-color: #fff;
            position: fixed;
            left: 45%;
            top: 40%;
            transform: translate(-50%,-50%);
            box-shadow:5px 6px 15px #666;
        }
        .update{
            color: #00a0df;
        }
        .delete{
            color: #00a0df;
        }
        .content{
            color: #00a0df;
        }
        .cont{
            width: 80px;
            height: 20px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
    </style>
    <script>
        $(document).ready(function () {
            $("#insertNews").click(function () {
                $("#insertform").show()
            })
            /*编辑*/
            $(".update").click(function () {
                var td = $(this).parent()
                var tds = td.siblings()
                var nno = $(tds[0]).text()
                var ntitle = $(tds[1]).text()
                var ncontent = $(tds[2]).text()
                $("#upnno").val(nno)
                $("#uptitle").val(ntitle)
                $("#upcontent").val(ncontent)
                $("#updateform").show()
            })
            $(".quite").click(function () {
                $(".mo").hide()
            })
            $(".delete").click(function () {
                var nno = $(this).attr('id')
                var is = confirm("确定要删除"+nno+"吗")

                if(is){
                    window.location.href="/admin/deleteNews?nno="+nno;
                }
            })
            /*详情*/
            $(".content").click(function () {
                var td = $(this).parent()
                var tds = td.siblings()
                var nno = $(tds[0]).text()
                var ntitle = $(tds[1]).text()
                var ncontent = $(tds[2]).text()
                $("#conno").val(nno)
                $("#cotitle").val(ntitle)
                $("#cocontent").val(ncontent)
                $("#contentNews").show()
            })
        })
    </script>
</head>
<body>
<nav class="navbar navbar-inverse navbar-fixed-top">
    <div class="container-fluid">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="#">众筹管理平台</a>
        </div>
        <div id="navbar" class="navbar-collapse collapse">
            <ul class="nav navbar-nav navbar-right">
                <li><a href="index.jsp">首页</a></li>
                <li><a href="#">欢迎, ${manage.mname}</a></li>
                <li><a href="#" title="修改个人资料和密码的页面">设置</a></li>
                <li><a href="admin_login.jsp" title="退出登录">退出</a></li>
            </ul>
        </div>
    </div>
</nav>

<div class="container-fluid">
    <div class="row">
        <div class="col-sm-3 col-md-2 sidebar">
            <ul class="nav nav-sidebar">
                <li ><a href="index.jsp">首页</a></li>
            </ul>
            <ul class="nav nav-sidebar">
                <li><a href="/projectManagement/getAll">所有项目*</a></li>
                <li><a href="/projectManagement/getAllNoPro">项目审核</a></li>

                <li><a href="/projectManagement/getAllComment">项目评论</a></li>
                <li><a href="/projectManagement/getAllType">项目分类*</a></li>

            </ul>
            <ul class="nav nav-sidebar">
                <li><a href="/admin/getUsersByCon">注册用户</a></li>
                <li><a href="/admin/getUsersMoney">用户资金</a></li>
                <%--<li><a href="">用户日志</a></li>--%>
                <li><a href="/admin/getUsersReal">实名审核</a></li>
            </ul>
            <ul class="nav nav-sidebar">
                <li class="active"><a href="/admin/getNews">新闻管理</a></li>
                <li><a href="/admin/getQuestion">问题管理</a></li>
                <li><a href="/admin/admin_manage.jsp">管理用户</a></li>
                <%--<li><a href="">管理日志</a></li>--%>
            </ul>
        </div>
        <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
            <h1 class="page-header">新闻咨询</h1>
            <div class="panel panel-default">
                <button type="button" class="btn btn-default btn-primary" id="insertNews">发布新闻</button>
            </div>
            <div class="panel panel-default">
                <div class="panel-heading">
                    <div class="panel-title">
                        所有新闻
                    </div>
                </div>
                <div class="panel-body">
                    <div class="table-responsive ">
                        <table class="table table-striped table-bordered">
                            <thead>
                            <tr>
                                <th>编号</th>
                                <th>标题</th>
                                <th>内容</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <c:forEach items="${pageinfo.list}" var="news">
                                <tr>
                                    <td>${news.nno}</td>
                                    <td>${news.ntitle}</td>
                                    <td><div class="cont">${news.ncontent}</div></td>
                                    <td>
                                        <span class="update">编辑</span>
                                        <span class="delete" id="${news.nno}">删除</span>
                                        <span class="content">详情</span>
                                    </td>
                                </tr>
                            </c:forEach>
                            </tbody>
                        </table>
                    </div>

                    <nav aria-label="Page navigation" class="text-right">

                        <ul class="pagination">
                            <h3>当前页:${pageinfo.pageNum}</h3>
                            <c:if test="${!pageinfo.isFirstPage}">
                                <li><a href="/admin/getNews?&page=1">首页</a></li>
                                <li><a href="/admin/getNews?&page=${pageinfo.prePage}">上一页</a></li>
                            </c:if>
                            <c:forEach items="${pageinfo.navigatepageNums}" var="page">
                                <li><a href="/admin/getNews?com=${con}&page=${page}">${page}</a> </li>
                            </c:forEach>
                            <c:if test="${!pageinfo.isLastPage}">
                                <li><a href="/admin/getNews?&page=${pageinfo.nextPage}">下一页</a></li>
                                <li><a href="/admin/getNews?&page=${pageinfo.pages}">末页</a></li>
                            </c:if>
                        </ul>
                    </nav>
                </div>
            </div>
        </div>
    </div>
</div>
<div id="insertform" class="mo">
    <h2>发布新闻</h2>
    <form class="form-horizontal" method="post" action="/admin/insertNews">
        <div class="form-group">
            <label for="ntitle" class="col-sm-2 control-label">标题</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" id="ntitle" placeholder="ntitle" name="ntitle">
            </div>
        </div>
        <div class="form-group">
            <label for="ncontent" class="col-sm-2 control-label">内容</label>
            <div class="col-sm-10">
                <textarea rows="10" type="text" class="form-control" id="ncontent" placeholder="ncontent" name="ncontent"></textarea>
            </div>
        </div>
        <button type="submit" class="btn btn-default">发布</button>
        <button type="button" class="btn btn-default quite">取消</button>
    </form>
</div>
<div class="mo" id="updateform">
    <h2>编辑</h2>
    <form class="form-horizontal" method="post" action="/admin/updateNews">
        <div class="form-group">
            <label for="upnno" class="col-sm-2 control-label">编号</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" id="upnno" placeholder="upnno" name="nno" readonly="readonly">
            </div>
        </div>
        <div class="form-group">
            <label for="uptitle" class="col-sm-2 control-label">标题</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" id="uptitle" placeholder="uptitle" name="ntitle">
            </div>
        </div>
        <div class="form-group">
            <label for="upcontent" class="col-sm-2 control-label">内容</label>
            <div class="col-sm-10">
                <textarea rows="10" type="text" class="form-control" id="upcontent" placeholder="upcontent" name="ncontent"></textarea>
            </div>
        </div>
        <button type="submit" class="btn btn-default">更改</button>
        <button type="button" class="btn btn-default quite">取消</button>
    </form>
</div>
<div class="mo" id="contentNews">
    <h2>详细信息</h2>
    <form class="form-horizontal">
        <div class="form-group">
            <label for="conno" class="col-sm-2 control-label">编号</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" id="conno" placeholder="conno" readonly="readonly">
            </div>
        </div>
        <div class="form-group">
            <label for="cotitle" class="col-sm-2 control-label">标题</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" id="cotitle" placeholder="cotitle" readonly="readonly">
            </div>
        </div>
        <div class="form-group">
            <label for="cocontent" class="col-sm-2 control-label">内容</label>
            <div class="col-sm-10">
                <textarea rows="10" type="text" class="form-control" id="cocontent" placeholder="cocontent" readonly="readonly"></textarea>
            </div>
        </div>
        <button type="button" class="btn btn-default quite">关闭</button>
    </form>
</div>
</body>
</html>
